// @ts-ignore
import styled from "styled-components";

/**
 * propsType用来定义样式中接收的参数
 * 当然也可以写在尖括号内部，为了代码的易读性
 * 我们放在了外面，
 *
 * !!!!!注意，所有的变量名前面必须加 $ 符号，否者就报错!!!!!
 *
 */
type propsType ={
  $isShow?: Boolean,
  $color?: String,
  $isFullScreen?:Boolean,
  $size?:"small" | "large" | "normal",
  $title?:String,
  $scrollY?:number,
};
const HyLoadingStyle = styled.div<propsType>`
  display: ${(props:propsType)=> props.$isShow?"flex":"none"};
  position: ${(props:propsType)=>props.$isFullScreen?"fixed":"absolute"};
  top: 0;
  left: 0;
  margin: 0;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  width: ${(props:propsType)=>props.$isFullScreen?"100vw":"100%"};
  height:  ${(props:propsType)=>props.$isFullScreen?"100vh":"100%"};
  background-color: rgba(0,0,0,.3);
  vertical-align: middle;
  z-index: 10;
  

  .loading-dot{
    display: inline-block;
    position: relative;
    font-size: ${(props:propsType)=>props.$size==="small"?18:props.$size==="large"?50:30}px;
    // top: ${(props:propsType)=>props.$scrollY?`calc(${props.$scrollY}px / )`:"0px"};;
    //left: 50%;
    top: 0;
    width: 1em;
    height: 1em;
    transform: rotate(45deg);
    animation-name: mymove;
    animation-duration: 2s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
  }
  // .loading-dot::after{
  //   content: '${(props:propsType)=>props.$size?`calc(${props.$scrollY}px / )`:"px"};';
  //   position: absolute;
  //   z-index: 100;
  //   font-size: 50px;
  //   color: #FFFFFF;
  // }
  .loading-dot-item{
    position: absolute;
    display: block;
    width: ${(props:propsType)=>props.$size==="small"?9:props.$size==="large"?25:15}px;
    height:${(props:propsType)=>props.$size==="small"?9:props.$size==="large"?25:15}px;
    background-color: ${(props:propsType)=>props.$color?props.$color:'var(--theme-color)'};
    border-radius: 50%;
    transform: scale(0.75);
    transform-origin: 50% 50%;
    opacity: 0.3;
    animation-name: myMove;
    animation-duration: 1s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
    animation-direction: alternate;
  }
  .loading-dot-item::after{
    box-sizing: border-box;
  }
  .loading-dot-item:nth-child(1){
    top: 0;
    inset-inline-start: 0;
    animation-delay: 0s;
  }
  .loading-dot-item:nth-child(2){
    top: 0;
    inset-inline-end: 0;
    animation-delay: .4s;
  }
  .loading-dot-item:nth-child(3){
   bottom: 0;
    inset-inline-start: 0;
    animation-delay: .8s;
  }
  .loading-dot-item:nth-child(4){
    bottom: 0;
    inset-inline-end: 0;
    animation-delay: 1.2s;
  }
  .hy-loding-ttile{
    margin: 5px auto;
    font-size: ${(props:propsType)=>props.$size==="small"?15:props.$size==="large"?29:21}px;;
    color: ${(props:propsType)=>props.$color?props.$color:'var(--theme-color)'};;
    font-weight: 100;
  }
  
  @keyframes mymove {
    to{
      transform: rotate(405deg);
    }
  }
  @keyframes myMove{
    100%{
      opacity: 1;
    }
  }
`;

export default HyLoadingStyle;
